};
#endif
-/* XXX application state */
-static long nr_pages = 0;
-static unsigned long *page_array = NULL;
static int current_domid = -1;
static int current_isfile;
return (void *)((unsigned long)v | (va & (PAGE_SIZE - 1)));
}
+#ifdef __x86_64__
+static void *
+map_domain_va(
+ int xc_handle,
+ int cpu,
+ void *guest_va,
+ int perm)
+{
+ unsigned long l3p, l2p, l1p, p, va = (unsigned long)guest_va;
+ uint64_t *l4, *l3, *l2, *l1;
+ static void *v;
+
+ if ((ctxt[cpu].ctrlreg[4] & 0x20) == 0 ) /* legacy ia32 mode */
+ return map_domain_va_pae(xc_handle, cpu, guest_va, perm);
+
+ if (fetch_regs(xc_handle, cpu, NULL))
+ return NULL;
+
+ l4 = xc_map_foreign_range(
+ xc_handle, current_domid, PAGE_SIZE, PROT_READ, ctxt[cpu].ctrlreg[3] >> PAGE_SHIFT);
+ if ( l4 == NULL )
+ return NULL;
+
+ l3p = l4[l4_table_offset(va)] >> PAGE_SHIFT;
+ l3 = xc_map_foreign_range(xc_handle, current_domid, PAGE_SIZE, PROT_READ, l3p);
+ if ( l3 == NULL )
+ return NULL;
+
+ l2p = l3[l3_table_offset(va)] >> PAGE_SHIFT;
+ l2 = xc_map_foreign_range(xc_handle, current_domid, PAGE_SIZE, PROT_READ, l2p);
+ if ( l2 == NULL )
+ return NULL;
+
+ l1p = l2[l2_table_offset(va)] >> PAGE_SHIFT;
+ l1 = xc_map_foreign_range(xc_handle, current_domid, PAGE_SIZE, perm, l1p);
+ if ( l1 == NULL )
+ return NULL;
+
+ p = l1[l1_table_offset(va)] >> PAGE_SHIFT;
+ if ( v != NULL )
+ munmap(v, PAGE_SIZE);
+ v = xc_map_foreign_range(xc_handle, current_domid, PAGE_SIZE, perm, p);
+ if ( v == NULL )
+ return NULL;
+
+ return (void *)((unsigned long)v | (va & (PAGE_SIZE - 1)));
+}
+#endif
+
+#ifdef __i386__
+/* XXX application state */
+static long nr_pages = 0;
+static unsigned long *page_array = NULL;
+
static void *
map_domain_va(
int xc_handle,
static unsigned long page_phys[MAX_VIRT_CPUS];
static unsigned long *page_virt[MAX_VIRT_CPUS];
static int prev_perm[MAX_VIRT_CPUS];
- static enum { MODE_UNKNOWN, MODE_32, MODE_PAE } mode;
+ static enum { MODE_UNKNOWN, MODE_32, MODE_PAE, MODE_64 } mode;
if ( mode == MODE_UNKNOWN )
{
xen_capabilities_info_t caps;
(void)xc_version(xc_handle, XENVER_capabilities, caps);
- mode = MODE_32;
- if ( strstr(caps, "_x86_32p") )
+ if ( strstr(caps, "-x86_64") )
+ mode = MODE_64;
+ else if ( strstr(caps, "-x86_32p") )
mode = MODE_PAE;
+ else if ( strstr(caps, "-x86_32") )
+ mode = MODE_32;
}
if ( mode == MODE_PAE )
return (void *)(((unsigned long)page_virt[cpu]) | (va & BSD_PAGE_MASK));
}
+#endif
+
static int
__xc_waitdomain(
int xc_handle,
#define PDRSHIFT 22
#define PSL_T 0x00000100 /* trace enable bit */
+#ifdef __x86_64__
+struct gdb_regs
+{
+ unsigned long r15;
+ unsigned long r14;
+ unsigned long r13;
+ unsigned long r12;
+ unsigned long rbp;
+ unsigned long rbx;
+ unsigned long r11;
+ unsigned long r10;
+ unsigned long r9;
+ unsigned long r8;
+ unsigned long rax;
+ unsigned long rcx;
+ unsigned long rdx;
+ unsigned long rsi;
+ unsigned long rdi;
+ unsigned long orig_rax;
+ unsigned long rip;
+ unsigned long xcs;
+ unsigned long eflags;
+ unsigned long rsp;
+ unsigned long xss;
+ unsigned long fs_base;
+ unsigned long gs_base;
+ unsigned long xds;
+ unsigned long xes;
+ unsigned long xfs;
+ unsigned long xgs;
+};
+
+#define SET_PT_REGS(pt, xc) \
+{ \
+ pt.r8 = xc.r8; \
+ pt.r9 = xc.r9; \
+ pt.r10 = xc.r10; \
+ pt.r11 = xc.r11; \
+ pt.r12 = xc.r12; \
+ pt.r13 = xc.r13; \
+ pt.r14 = xc.r14; \
+ pt.r15 = xc.r15; \
+ pt.rbx = xc.rbx; \
+ pt.rcx = xc.rcx; \
+ pt.rdx = xc.rdx; \
+ pt.rsi = xc.rsi; \
+ pt.rdi = xc.rdi; \
+ pt.rbp = xc.rbp; \
+ pt.rax = xc.rax; \
+ pt.rip = xc.rip; \
+ pt.xcs = xc.cs; \
+ pt.eflags = xc.eflags; \
+ pt.rsp = xc.rsp; \
+ pt.xss = xc.ss; \
+ pt.xes = xc.es; \
+ pt.xds = xc.ds; \
+ pt.xfs = xc.fs; \
+ pt.xgs = xc.gs; \
+}
+
+#define SET_XC_REGS(pt, xc) \
+{ \
+ xc.r8 = pt->r8; \
+ xc.r9 = pt->r9; \
+ xc.r10 = pt->r10; \
+ xc.r11 = pt->r11; \
+ xc.r12 = pt->r12; \
+ xc.r13 = pt->r13; \
+ xc.r14 = pt->r14; \
+ xc.r15 = pt->r15; \
+ xc.rbx = pt->rbx; \
+ xc.rcx = pt->rcx; \
+ xc.rdx = pt->rdx; \
+ xc.rsi = pt->rsi; \
+ xc.rdi = pt->rdi; \
+ xc.rbp = pt->rbp; \
+ xc.rax = pt->rax; \
+ xc.rip = pt->rip; \
+ xc.cs = pt->xcs; \
+ xc.eflags = pt->eflags; \
+ xc.rsp = pt->rsp; \
+ xc.ss = pt->xss; \
+ xc.es = pt->xes; \
+ xc.ds = pt->xds; \
+ xc.fs = pt->xfs; \
+ xc.gs = pt->xgs; \
+}
+
+#elif __i386__
+
struct gdb_regs {
long ebx; /* 0 */
long ecx; /* 4 */
int xss; /* 64 */
};
-
-#define printval(x) printf("%s = %lx\n", #x, (long)x);
#define SET_PT_REGS(pt, xc) \
{ \
pt.ebx = xc.ebx; \
xc.fs = pt->xfs; \
xc.gs = pt->xgs; \
}
+#endif
+#define printval(x) printf("%s = %lx\n", #x, (long)x);
#define vtopdi(va) ((va) >> PDRSHIFT)
#define vtopti(va) (((va) >> PAGE_SHIFT) & 0x3ff)
#endif